package com.ash.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ash.domain.AccountCostInfo;
import com.ash.service.AccountCostInfoService;
import com.ash.mapper.AccountCostInfoMapper;
import org.springframework.stereotype.Service;

/**
* @author admin
* @description 针对表【account_cost_info(消耗信息)】的数据库操作Service实现
* @createDate 2024-05-23 11:05:02
*/
@Service
public class AccountCostInfoServiceImpl extends ServiceImpl<AccountCostInfoMapper, AccountCostInfo>
    implements AccountCostInfoService{

    @Override
    public void moveData(String endDateStr) {
        /*操作时间范围  beginDateStr<costDate<=endDateStr*/
        String beginDateStr =this.baseMapper.queryMaxCostDateFromBackUp();
        this.baseMapper.dataCopy(beginDateStr, endDateStr);
        LambdaQueryWrapper<AccountCostInfo> wrapper = new LambdaQueryWrapper<>();
        wrapper.le(AccountCostInfo::getCostDate,endDateStr);
        if(StrUtil.isNotBlank(beginDateStr)){
            wrapper.gt(AccountCostInfo::getCostDate,beginDateStr);
        }
        wrapper.eq(AccountCostInfo::getDataFrequency,0);
        this.getBaseMapper().delete(wrapper);
    }
}




